package cn.huihuo.weibo.controller;

import cn.huihuo.weibo.bean.message.MessageResultBean;
import cn.huihuo.weibo.service.MessageService;
import cn.huihuo.weibo.service.ParticipationService;
import cn.jfinalbbs.common.BaseController;
import cn.jfinalbbs.common.Constants;
import cn.jfinalbbs.user.User;

/**
 * Created by zhengjunbo on 2015/11/2.
 */
public class MessageController extends BaseController {

    public void index(){
        User user = getSessionAttr(Constants.USER_SESSION);
        setAttr("participationSize", user==null?"": ParticipationService.service.findTotalParticipation(user.getStr("id")));
        render("huihuo/message.html");
    }


    public void getMessage(){
        Integer pageStep = getParaToInt("pageStep");
        Integer count = getParaToInt("count");

        User user = getSessionAttr(Constants.USER_SESSION);
        if(user==null){
            error("请登录后操作！");
            return;
        }
        MessageResultBean messageResultBean = MessageService.service.getMessage(pageStep, count, user.getStr("id"));
        success(messageResultBean);
    }




}
